package com.cxd.ancun.constants;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;

import org.jsoup.helper.StringUtil;

/**
 * <一句话功能简述> <功能详细描述>
 * @author wtj
 * @date 2016年4月6日 下午3:41:50
 * @company CXD
 * @version [Copyright (c) 2016 V001]
 */
public class AncunConstants {
	
	public static final String RECHARGE_CHANNEL = "易宝支付";
	// 红包抵扣 0元
	public static final String RED_DEDUCTION = "0";
	
	public static class ancunStatusCode{
		public static final int C100000 = 100000; // 成功
	}

	public static class ancunSendStatus{
		public static final int INIT = 0; // 0:初始化 
		public static final int SUCCESS = 1; // 1:成功 
		public static final int SEND_SUCCESS = 2; // 2:发送成功
		public static final int FAIL = 3; // 3:失败
	}
	public static class itemKey{
		// 投资
		public static final String INVEST = "I-0114001";
		// 充值
		public static final String RECHARGE = "I-0114002";
		// 提现
		public static final String WITHDRAW = "I-0114003";
		// 借款保全
		public static final String LOAN = "I-0114004";
	}
	
	// 投资交易过程保全
	public static class investFlowNo{
		//   投资交易信息保全
		public static final String INVEST = "X-0377001";
		//  募集结束日期追加
		public static final String ADD_LOAN_END_TIME = "X-0377002";
		//   投资协议追加
		public static final String ADD_CONTRACT = "X-0377003";
		//   实际回款清单追加
		public static final String ADD_REPAY = "X-0377004";
	}
	
	// 借款交易过程保全
	public static class loanFlowNo{
		//  投资交易信息保全
		public static final String LOAN = "X-0400001";
		//  募集结束日期追加
		public static final String ADD_LOAN_END_TIME = "X-0400002";
	}
	
	/**
	 * 用户银行卡状态
	 * @author wlsnow
	 *
	 */
	public static class BankCard{
		public static final String VERIFIED = "VERIFIED";
	}
	
	/**
	 * 银行卡 map 常亮 code:name
	 */
	public static final Map<String,String> bankCodeNameMap = new HashMap<String,String>();
	
	public String getBankNameByNo(final String bankNo){
		String bankName = bankCodeNameMap.get(bankNo.toUpperCase().trim());
		if(StringUtil.isBlank(bankName)){
			return "Not found Bank";
		}
		return bankName;
	}
	private static Properties props = new Properties(); 
	static{
		try {
			props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("banks.properties"));
			Iterator<Entry<Object, Object>> it = props.entrySet().iterator(); 
			while(it.hasNext()){
				Entry<Object, Object> entry = it.next();  
	            String key = (String) entry.getKey();  
	            String value = (String) entry.getValue();  
	            bankCodeNameMap.put(key.toUpperCase().trim(), value);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
